package net.esj.basic.core.engine.support.validator;

import java.util.Set;

import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
import org.hibernate.validator.constraints.NotEmpty;

import net.esj.basic.dao.hibernate.HibernateDao;
import net.esj.basic.dao.hibernate.impl.HibernateDaoImpl;

/**
 * 做一个自定义邮箱，身份证等的效验
 * @author Administrator
 *
 */
public class ValidateTest {
	
	@NotEmpty
	@Size(min=10,max=12,message="{ValidateTest}")
	private String name;
	
	private int ii;
	
	static Configuration<HibernateValidatorConfiguration> config= Validation.byProvider(HibernateValidator.class).configure();
	static ValidatorFactory vf = config.buildValidatorFactory();
	static Validator v  = vf.getValidator();
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ValidateTest vt = new ValidateTest();
		vt.name = "时阿斯顿阿斯打算打";
		Set<ConstraintViolation<ValidateTest>> set = v.validate(vt);
		for(ConstraintViolation<ValidateTest> tmp:set){
			System.out.println(tmp.getMessageTemplate());
		}
		
		//HibernateBaseDao d = new HibernateBaseDaoImpl();
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getIi() {
		return ii;
	}
	public void setIi(int ii) {
		this.ii = ii;
	}
	

}
